package com.example.service;

import com.example.entity.MapCheckPoint;
import com.example.mapper.MapCheckPointMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
关卡业务处理
 */
@Service
public class MapCheckPointService {

    @Resource
    private MapCheckPointMapper mapcheckpointMapper;

    public void add(MapCheckPoint mapCheckPoint) {
        mapcheckpointMapper.insert(mapCheckPoint);
    }

    public void deleteById(Integer id) {
        mapcheckpointMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(MapCheckPoint mapCheckPoint) {
        mapcheckpointMapper.updateById(mapCheckPoint);
    }

    public MapCheckPoint selectById(Integer id) {
        return mapcheckpointMapper.selectById(id);
    }

    public List<MapCheckPoint> selectAll(MapCheckPoint mapCheckPoint) {
        return mapcheckpointMapper.selectAll(mapCheckPoint);
    }

    public PageInfo<MapCheckPoint> selectPage(MapCheckPoint mapCheckPoint, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MapCheckPoint> checkpointList = mapcheckpointMapper.selectAll(mapCheckPoint);
        return PageInfo.of(checkpointList);
    }
}
